#ifndef __INCLUDE_DEMO_PROC_H__
#define __INCLUDE_DEMO_PROC_H__
//=======================================================================//
//= Include files.                                                      =//
//=======================================================================//
#include <stdlib.h>
#include <stdio.h>
#include "SGUI_Typedef.h"
#include "SGUI_Common.h"
#include "HMI_Engine.h"
#include "DemoActions.h"
#include "Resource.h"
#ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_
#include "simulator_if.h"
#endif

//=======================================================================//
//= Data type definition.                                               =//
//=======================================================================//
// HMI action type
typedef enum
{
    EVENT_ID_UNKNOW =               0,
    // User defined action type.
    EVENT_ID_KEY_PRESS,
    EVENT_ID_TIMER,
    EVENT_ID_RTC,
    EVENT_ID_LEQ,
    EVENT_ID_CALIB,
    EVENT_ID_SET,
    // User defined action above.
    EVENT_ID_MAX
}EVENT_ID;

// HMI event type.
typedef enum
{
    EVENT_TYPE_ANY =                0,
    EVENT_TYPE_ACTION,
    EVENT_TYPE_DATA,
}EVENT_TYPE;

enum DEMO_PROC_ACTION_ID
{
    HMI_DEMO_PROC_NO_ACT =          0,
    HMI_DEMO_PROC_CONFIRM =         1,
    HMI_DEMO_PROC_CANCEL =          2,
};

typedef struct
{
    SGUI_UINT16     uiKeyValue;
}KEY_EVENT_DATA;

typedef struct
{
    SGUI_UINT        iValue;
}DUMMY_DATA_EVENT_DATA;

typedef struct 
{
    SGUI_UINT        uLeqA;
    SGUI_UINT        uLeqC;
    SGUI_UINT        uLeqZ;
    SGUI_INT         uWeightType;    // 0A 1C 2Z
    SGUI_UINT        uTimeWeightType;// 0Slow 1Fast
    SGUI_UINT        uChargeStatus;  // 0 1Charging
    SGUI_UINT        uHoldStatus;    // 0 unhold;  1 hold
}LEQ_DATA_EVENT_DATA;


/*app-->gui*/
typedef struct
{
    long type;
    /* 	1:APP->GUI acz leq fast/slow  hold:
        2:APP->GUI calibrate status
    */
    float fleq1;
    float fleq2;
    float fleq3;
    uint8_t fs;   /*0---slow  1---fast  2---peak*/
    uint8_t hold; /*0---nohold  1---hold*/
    uint8_t alarm_type; /*0---null  1---lowvalue  2---overload*/
    int  status;  /*0:slow unhold  1:slow hold 2:fast unhold 3:fast hold*/
} ghdMessage_t;
#define GHDMESS_SIZE (sizeof(float) * 3 + sizeof(int) + sizeof(uint8_t) * 3)

HMI_EVENT_TYPE_DECLARE(KEY_PRESS_EVENT, KEY_EVENT_DATA);
HMI_EVENT_TYPE_DECLARE(DATA_EVENT, DUMMY_DATA_EVENT_DATA);
HMI_EVENT_TYPE_DECLARE(LEQ_EVENT, LEQ_DATA_EVENT_DATA);

//=======================================================================//
//= Macro definition.                                                   =//
//=======================================================================//
#define     HMI_SCREEN_ID_DEMO_SCROLLING_TEXT           (1001)
#define     HMI_SCREEN_ID_DEMO_PAINT_TEXT               (1002)
#define     HMI_SCREEN_ID_DEMO_LIST                     (1003)
#define     HMI_SCREEN_ID_DEMO_TEXT_NOTICE              (1004)
#define     HMI_SCREEN_ID_DEMO_BASIC_PAINT              (1005)
#define     HMI_SCREEN_ID_DEMO_VARIABLE_BOX             (1006)
#define     HMI_SCREEN_ID_DEMO_REAL_TIME_GRAPH          (1007)
#define     HMI_SCREEN_ID_DEMO_MENU                     (1008)
#define     HMI_SCREEN_ID_DEMO_CURVE                    (1009)
#define     HMI_SCREEN_ID_DEMO_POLOR_COORD              (1010)
// add new
#define     HMI_SCREEN_ID_MeasureB_PAINT              (1011)
#define     HMI_SCREEN_ID_MeasureA_PAINT              (1012)
#define     HMI_SCREEN_ID_Calibrate_PAINT             (1013)
#define     HMI_SCREEN_ID_Statistics_PAINT            (1014)
#define     HMI_SCREEN_ID_Set_PAINT                   (1015)
#define     HMI_SCREEN_ID_SetMenu_PAINT               (1016)


#define     DEMO_HEART_BEAT_INTERVAL_MS                 (20)

//=======================================================================//
//= Public variable declaration.                                        =//
//=======================================================================//
/* HMI engine object. */
extern HMI_ENGINE_OBJECT        g_stDemoEngine;
/* Screen display objects. */
extern HMI_SCREEN_OBJECT        g_stHMIDemo_ScrollingText;
extern HMI_SCREEN_OBJECT        g_stHMIDemo_List;
extern HMI_SCREEN_OBJECT        g_stHMIDemo_Notice;
extern HMI_SCREEN_OBJECT        g_stHMIDemo_RTCNotice;
extern HMI_SCREEN_OBJECT        g_stHMIDemo_VariableBox;
extern HMI_SCREEN_OBJECT        g_stHMIDemo_RealtimeGraph;
extern HMI_SCREEN_OBJECT        g_stHMIDemo_Menu;
extern HMI_SCREEN_OBJECT        g_stHMIDemo_BasicPaint;
extern HMI_SCREEN_OBJECT        g_stHMIDemo_TextPaint;
extern HMI_SCREEN_OBJECT        g_stHMIDemo_Curve;
extern HMI_SCREEN_OBJECT		g_stHMIDemo_PolorCoord;

extern HMI_SCREEN_OBJECT		g_stHMIMeasureAPaint;
extern HMI_SCREEN_OBJECT		g_stHMIMeasureBPaint;
extern HMI_SCREEN_OBJECT        g_stHMICalibratePaint;
extern HMI_SCREEN_OBJECT        g_stHMISetPaint;
extern HMI_SCREEN_OBJECT        g_stHMISet_Menu;

extern char time_str[64];
extern LEQ_DATA_EVENT_DATA  LeqData;

//=======================================================================//
//= Function declare.                                                   =//
//=======================================================================//
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
HMI_ENGINE_RESULT   InitializeHMIEngineObj(void);
void                DemoMainProcess(void);

bool                SysTickTimerTriggered(void);
bool                RTCTimerTriggered(void);
bool                UserEventTriggered(void);
bool                AppEventTriggered(void);

void                SysTickTimerEnable(bool bEnable);
void                RTCTimerEnable(bool bEnable);

SGUI_UINT           GetBatteryValue(void);

#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif // __INCLUDE_DEMO_PROC_H__
